<?php


namespace App\Transformers\Live;

use App\Models\LiveRoom;
use League\Fractal\TransformerAbstract;

class LiveRoomTransformer extends TransformerAbstract
{
    public function transform(LiveRoom $data)
    {
        return [
            'id' => $data->id,
            'room_id' => $data->room_id ?? "",
            'anchor_id' => $data->anchor_id ?? "",
            'name' => $data->name ?? "",
            'cover_img' => $data->cover_img ?? "",
            'cover_img_url' => 'https://placeimg.com/640/480/any',
            'share_img' => $data->share_img ?? "",
            'share_img_url' => 'https://placeimg.com/640/480/any',
            'start_at' => $data->start_at ?? "",
            'end_at' => $data->end_at ?? "",
            'error_msg' => $data->error_msg ?? "",
            'mark' => $data->mark ?? "",
            'sort' => $data->sort ?? "",
            'room_type' => $data->room_type ?? "",
            'room_type_text' => $data->roomTypeEnum[$data->room_type] ?? "",
            'screen_type' => $data->screen_type ?? "",
            'screen_type_text' => $data->screenTypeEnum[$data->screen_type] ?? "",
            'live_status' => $data->live_status ?? "",
            'live_status_text' => $data->liveStatusEnum[$data->live_status] ?? "",
            'status' => $data->status ?? "",
            'status_text' => $data->StatusEnum[$data->status] ?? "",
            'is_openLike' => $data->is_openLike ?? 0,
            'is_openShelf' => $data->is_openShelf ?? 0,
            'is_openComments' => $data->is_openComments ?? 0,
            'is_show' => $data->is_show ?? 0,
            'replay_status' => $data->replay_status ?? 0,
            'live_anchor' =>$data->liveAnchor ?? "",
            'deleted_at' => $data->deleted_at ? $data->deleted_at->format("Y-m-d H:i:s") : '',
            'created_at' => $data->created_at ? $data->created_at->format("Y-m-d H:i:s") : '',
            'updated_at' => $data->updated_at ? $data->updated_at->format("Y-m-d H:i:s") : '',
        ];
    }

}
